<%@page import="com.lw.db.DBPhnnujwc"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>反馈系统</title>
<link href="css/mgscss.css" rel="stylesheet">
<link href="js/bootstrap-combined.min.css" rel="stylesheet"
	media="screen">
<script type="text/javascript" src="js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="js/jquery-ui"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	var s = "";
	s += " 网页可见区域宽：" + document.body.clientWidth;
	s += " 网页可见区域高：" + document.body.clientHeight;
	s += " 网页可见区域宽：" + document.body.offsetWidth + " (包括边线和滚动条的宽)";
	s += " 网页可见区域高：" + document.body.offsetHeight + " (包括边线的宽)";
	s += " 网页正文全文宽：" + document.body.scrollWidth;
	s += " 网页正文全文高：" + document.body.scrollHeight;
	s += " 网页被卷去的高(ff)：" + document.body.scrollTop;
	s += " 网页被卷去的高(ie)：" + document.documentElement.scrollTop;
	s += " 网页被卷去的左：" + document.body.scrollLeft;
	s += " 网页正文部分上：" + window.screenTop;
	s += " 网页正文部分左：" + window.screenLeft;
	s += " 屏幕分辨率的高：" + window.screen.height;
	s += " 屏幕分辨率的宽：" + window.screen.width;
	s += " 屏幕可用工作区高度：" + window.screen.availHeight;
	s += " 屏幕可用工作区宽度：" + window.screen.availWidth;
	s += " 你的屏幕设置是 " + window.screen.colorDepth + " 位彩色";
	s += " 你的屏幕设置 " + window.screen.deviceXDPI + " 像素/英寸";
	//alert(s);
	document.getElementById("divsc").style.height = 300 + "px;"
	function msg(odid) {
		var msg = document.getElementById("msg").value;
		if (msg == "" || msg == null) {
			document.getElementById("msg").focus();
			//alert("您没写回复信息！");
			return;
		}
		Methods.addMsg(odid, msg);
	}
	
	/**更新消息列表*/
	function updatemsglist(time,name,content) {
		 var strr1="<div class='clear'></div><div class='divtime'><small>";	 
		 var strr2="</small></div><div class='divimg2'><img class='imghead' src='images/hnnubg.jpg' ></div><div class='divright2'><div class='divuser2'>";	 
		 var strr3="</div><div class='divmsg2'>";	 
		 var strr4="</div></div>";
		
		var str=strr1+time+strr2+name+strr3+content+strr4;
		var u = document.getElementById("divsc");
		u.insertAdjacentHTML("beforeEnd", str );
		document.getElementById('divsc').scrollTop = document.getElementById('divsc').scrollHeight;
	}
</script>

<%
	String h = "300px";
%>
</head>
<body>

	<div class="row-fluid">
		<div class="span12">
			<div class="row-fluid">
				<div class="span12">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">×</button>
						<h4 align="center" class="modal-title" id="myModalLabel2">消息记录</h4>
					</div>
					<div id="divsc" style=" height:<%=h%>; overflow: scroll; ">


						

						<%
						String teststr="";
						
							String odid = request.getParameter("odid");
                            String strl1="<div class='clear'></div><div class='divtime'><small>";
                            String strl2="</small></div><div class='divimg'><img class='imghead' src='images/userhead.jpg' class='img-circle'></div><div class='divright'><div class='divuser'>";
                            String strl3="</div><div class='divmsg'>";
                            String strl4="</div></div>";
                            
                            String strr1="<div class='clear'></div><div class='divtime'><small>";
                            String strr2="</small></div><div class='divimg2'><img class='imghead' src='images/hnnubg.jpg' ></div><div class='divright2'><div class='divuser2'>";
                            String strr3="</div><div class='divmsg2'>";
                            String strr4="</div></div>";
							Connection conn = null;
							ResultSet rs = null;
							Statement stmt = null;
							try {
								StringBuffer msglist = new StringBuffer();
								String sql = "", sql2 = "";
								String name="";

								sql = "select * from jxfk where id=" + odid;
								sql2 = "select * from jxfk_msg where odid=" + odid
										+ " order by daytime asc";

								conn = DBPhnnujwc.getPool().getConnection();
								stmt = conn.createStatement();
								rs = stmt.executeQuery(sql);

								while (rs.next()) {//左
									name=rs.getString("openID");
									
									msglist.append(strl1);
									msglist.append(rs.getString("daytime"));
									msglist.append(strl2);
									msglist.append(name);
									msglist.append(strl3);
									msglist.append(rs.getString("content"));
									msglist.append(strl4);
								}

								rs.last();
								rs = stmt.executeQuery(sql2);
								while (rs.next()) {
									int role = rs.getInt("role");

									switch (role) {
									case 0:
										msglist.append(strl1);
										msglist.append(rs.getString("daytime"));
										msglist.append(strl2);
										msglist.append(name);
										msglist.append(strl3);
										msglist.append(rs.getString("content"));
										msglist.append(strl4);
										break;
									case 1:
										msglist.append(strr1);
										msglist.append(rs.getString("daytime"));
										msglist.append(strr2);
										msglist.append("海南师大教务处");
										msglist.append(strr3);
										msglist.append(rs.getString("content"));
										msglist.append(strr4);
										
										teststr=msglist.toString();
										break;
									default:
										break;

									}

								}
								out.print(msglist.toString());
								msglist.delete(0, msglist.length());
								msglist = null;
							} catch (Exception e) {
								out.print(e.toString());
							} finally {

								try {
									rs.close();
								} catch (Exception e2) {
									// TODO: handle exception
								}
								try {
									stmt.close();
								} catch (Exception e2) {
									// TODO: handle exception
								}
								try {
									conn.close();
								} catch (Exception e2) {
									// TODO: handle exception
								}

							}
							
						%>




					</div>
				</div>

				<div class="modal-footer">
					<div align="center" style="margin-bottom: 10px"">
						<textarea id="msg" style="width:95%" id="msg" class="form-control"
							rows="3"></textarea>
					</div>
					
					<button type="button" class="btn btn-default" data-dismiss="modal">
						关闭</button>
						<button type="button" class="btn btn-primary"
							onclick="msg('<%=odid%>')">&nbsp;发&nbsp;&nbsp;&nbsp;&nbsp;送&nbsp;</button>
				</div>
			</div>
		</div>
	</div>
</body>
</html>